﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
using System.Configuration;
using System.Collections.Specialized;

namespace KingSite.Library.Log {
    public class LogHelper {
        static ILogSetting logSetting = new LogSetting();

        public static ILog GetInstance() {
            string[] type = logSetting.LogType.Split(',');
            string a = type[1];
            string n = type[0];
            Assembly ass = Assembly.Load(a);
            Type[] t = ass.GetTypes();
            object o = ass.CreateInstance(n);
            return (ILog)o;
        }

    }

    public interface ILogSetting {
        string LogType { get; }
    }

    public class LogSetting : ILogSetting {
        public string LogType {
            get { return ((NameValueCollection)ConfigurationManager.GetSection("KingSiteLibrary/Log"))["LogType"]; }
        }

    }
}
